<?php
defined('BY_JYA') or exit('error');
/*
	会员中心
*/
$_RQ['op']=$_RQ['op']?$_RQ['op']:'main';
cfc('core')->checklogin();
if($_RQ['op']=='main'){
	$member=$this->get('member',array('mid'=>$_SESSION['uid']));
	if(!$member){
		$member=$this->create_member();
	}
	$member['username']=pdo_getcolumn('core_members',array('id'=>$_SESSION['uid']),'username');
	$member['url']=custom_url('jy_move_agentcar/member.join//mid='.$member['mid'],true);
	$card=$this->get('cards',array('mid'=>$_SESSION['uid']),'number');
	if($card){
		$member['card_number']=$this->card_number($card['number']);
	}
	$setting=$this->plugin_setting('basic');
	$return['item']=$member;
	$return['setting']=$setting;
	$agent=$this->get('agent',array('mid'=>$_SESSION['uid']));
	if($agent){
		$return['agent']=$agent;
	}
	if($_SESSION['os']=='windows'){
		$commission=pdo_getsum('jy_move_agentcar_commission',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');
		$balance=pdo_getsum('jy_move_agentcar_balance',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']),'fee');
		$pay=pdo_getsum('jy_move_agentcar_balance',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid'],'status'=>2),'fee');
		$return['item']['commission']=$commission?:0;
		$return['item']['balance']=$balance?:0;
		$return['item']['pay']=$pay?:0;
		$return['htmls']=array(
			'type'=>'look',
			'look'=>array(
				array('type'=>'string','name'=>'username','title'=>'我的账号'),
				array('type'=>'image','name'=>'avatar','title'=>'头像'),
				array('type'=>'price','name'=>'commission','title'=>'累计佣金'),
				array('type'=>'price','name'=>'balance','title'=>'累计已结算佣金'),
				array('type'=>'price','name'=>'pay','title'=>'累计已打款佣金'),
			),
		);
	}
	exi($return);
	
}
